import { defineStore } from 'pinia'

export const useUserStore = defineStore('user', {
  state: () => ({
    isLoggedIn: false,
    userInfo: {
      nickname: '',
      avatarUrl: '/images/default-avatar.png'
    }
  }),
  actions: {
    login(userData) {
      this.isLoggedIn = true
      this.userInfo = {
        nickname: userData.nickname,
        avatarUrl: userData.avatarUrl || '/images/default-avatar.png'
      }
    },
    logout() {
      this.isLoggedIn = false
      this.userInfo = { nickname: '', avatarUrl: '' }
    }
  },
  persist: true
});